﻿/**
*@description 转移公开客源
*/
Chenxin.UI.ShiftPubCustomerForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    actionUrl: 'service/CustomerMgr.ashx',
    id: 'shiftpubcustomerWin',
    renderTo: 'jqm_shiftpubcustomer',
    jqmWidth: 600,
    createForm: function() {
        return Chenxin.FormCommon.ShiftPubCustomerForm('shiftpubcustomer');
    },
    createComboList: function() {
        var _this=this;
        //城市
        this.city=new Chenxin.UI.StructCombo({
			param:{op:'getcity'},
			containerId:'#shiftpubcustomer_city',
			name:'CityId',
			inModelType:'all',
			txtModelName:'CityName',
			tbxWidth:97,
			afterLoadItems:function(){
				if(this.items.length==1){
					this.addPleaseSelected=false;
					this.initValue=this.items[0].val;
					_this.company.param.fatherid=this.items[0].val;
					_this.company.reload();
				}else{
					this.addPleaseSelected=true;			
				}
			},
			onSelected:function(){
				if(this.getValue()==this.defVal){
					_this.company.clearItems();
				}else{
					_this.company.param.fatherid=this.getValue();
					_this.company.reload();
				}
				_this.departs.clearItems();
				_this.emp.clearItems();
			}
		});
		
		//公司
		this.company=new Chenxin.UI.StructCombo({
			autoLoad:false,
			param:{op:'getcompany'},
			tbxWidth:97,
			name:'CompanyId',
			inModelType:'all',
			txtModelName:'CompanyName',
			containerId:'#shiftpubcustomer_company',
			afterLoadItems:function(){
				if(this.items.length==1){
					this.addPleaseSelected=false;
					this.initValue=this.items[0].val;
					_this.departs.param.fatherid=this.items[0].val;
					_this.departs.reload();
				}else{
					this.addPleaseSelected=true;					
				}
			},
			onSelected:function(){
				if(this.getValue()==this.defVal){
					_this.departs.clearItems();
				}else{
					_this.departs.param.fatherid=this.getValue();
					_this.departs.reload();
				}
				_this.emp.clearItems();
			}
		});
		//门店
		this.departs=new Chenxin.UI.StructCombo({
			autoLoad:false,
			tbxWidth:97,
			name:'OprDepartId',
			inModelType:'all',
			txtModelName:'OprDepart',
			containerId:'#shiftpubcustomer_departs',
			param: { op: 'getallotdeparts' },
			required:true,
			onSelected:function(){
				if(this.getValue()==this.defVal){
					_this.emp.clearItems();
				}else{
					_this.emp.param.fatherid=this.getValue();
					_this.emp.reload();
				}
			}
		});
		//人
		this.emp=new Chenxin.UI.StructCombo({
			autoLoad:false,
			tbxWidth:97,
			colWidth:100,
			name:'OprPersonId',
			inModelType:'all',
			txtModelName:'OprPerson',
			containerId:'#shiftpubcustomer_emp',
			required:true,
			param:{op:'getemployee',usertype:1}
		});
        
        return [this.city, this.company, this.departs, this.emp];
    },

    initEvent: function() {
        var _this = this;
        $('#shiftpubcustomer_save').live('click', function() {
            _this.op="shiftpubcustomer";
            _this.save();
        });
        $('#shiftpubcustomer_cancle').live('click', function() {
            _this.hide();
        });

    },
    initComponent: function() {
        Chenxin.UI.ShiftPubCustomerForm.superclass.initComponent.call(this);
    }
});

Chenxin.FormCommon.ShiftPubCustomerForm=function(comboIdPrefix){
return '<table class="tbl_f"><tbody><tr><th>客户姓名：</th><td colspan=3><input type="text"  maxlength="25"  name="CustomerName" class="inputbox_n" disabled="disabled"/></td></tr><tr><th>手机：</th><td><div style="float:left;"><input name="Mobile"  maxlength="11"  class="inputbox_n" id="Mobile" type="text" disabled="disabled"/></div></td><th>联系电话：</th><td><div style="float:left;"><input name="Phone" maxlength="50"  class="inputbox_n" id="Phone" type="text" disabled="disabled"/></div></td></tr><tr><th>操作部门：</th><td><input type="text" maxlength="50" name="OprDepart" class="inputbox_n" disabled="disabled"/></td><th>操作人员：</th><td><input type="text" maxlength="50" name="OprPerson" class="inputbox_n" disabled="disabled"/></td></tr><tr><th>目标城市：</th><td><div id="' + comboIdPrefix + '_city" style="z-index:776; margin-right: 2px;" class="SelectWrapSingle"></div></td><th>目标公司：</th><td><div id="' + comboIdPrefix + '_company" style="z-index:775; margin-right: 2px;" class="SelectWrapSingle"></div></td></tr><tr><th>目标部门：</th><td><div id="' + comboIdPrefix + '_departs" style="z-index:774; margin-right: 2px;" class="SelectWrapSingle"></div></td><th>目标人员：</th><td><div id="' + comboIdPrefix + '_emp" style="z-index:773; margin-right: 2px;" class="SelectWrapSingle"></div></td></tr><tr><td colspan="4"><input type="hidden"  name="CustomerId" /><div style="float:right; margin-right:15px;_margin-right:10px;*+margin-right:19px;"><a class="btn_n fl"  href="#"  id="' + comboIdPrefix + '_save"><span>提交</span></a><a id="' + comboIdPrefix + '_cancle" class="btn_n fl"  href="#" ><span>关闭</span></a></div></td></tr></tbody></table>';
};
